﻿using RightControl.IRepository;
using RightControl.IService;
using RightControl.Model;
using RightControl.Repository;
using RightControl.Repository.PlatForm;
using System.Collections.Generic;

namespace RightControl.Service {
    public class FieldMapService : BaseService<FieldMap>, IFieldMapService {
        public IFieldMapRepository repository { get; set; }


        public dynamic GetListByFilter(FieldMap filter, PageInfo pageInfo) {
            return GetListByFilter(filter, pageInfo);
        }


        public Dictionary<string, string> GetFieldMaps(FieldMap filter, PageInfo pageInfo) {
            Dictionary<string, string> fieldMap = new Dictionary<string, string>();
            string _where = " where 1=1";
            _where += " And Platform=" + filter.Platform;
            dynamic ret = GetListByFilter(filter, pageInfo, _where);
            if (ret != null && ret.count > 0) {
                for (int i = 0; i < ret.count; i++) {
                    fieldMap[ret.data[i].OriginVal] = ret.data[i].MappedVal;
                }
            }
            return fieldMap;
        }
    }
}